<!--#include virtual="/dzps/p1.asp"-->
<script language="JScript" runat="Server">
    function ToObject(json) {
        var o;
        eval("o=" + json);
        return o;
    }

    function toArray(s) {
        var dic = Server.CreateObject("Scripting.Dictionary")
        eval("var a=" + json);
        for (var i = 0; i < a.length; i++) {
            var obj = Server.CreateObject("Scripting.Dictionary")
            for (x in a[i]) obj.Add(x, a[i][x])
            dic.Add(i, obj);
        }
        return dic
    }
</script>
<%
dim action,ret,sql,rs,json
json = request.form
action=Easp.Var("action")

select case action
	case "upf_1_add" 		upf_1_add
	case "upf_1_upd" 		upf_1_upd
	case "upf_1_del" 		upf_1_del
	case "upf_1_lst" 		upf_1_lst
	case "code_add" 		code_add
	case "get_m_f" 			get_m_f
	case "runr_get0" 		runr_get0
	case "code_del" 		code_del
	case "log1_get" 		log1_get
	case "code_list" 		code_list
	case "r_session"		r_session
end select
function upf_1_add()
	dim sqla(10)
	vas "mode","upf_1"
	sqla(0)=cr2("[baseinfo]","mode,name1,name2,name3")
	ret=execsw(sqla)
	rt ret
end function
Function upf_1_del()
	dim ret
	ret = Easp.Db.Del("[baseinfo]","id={id:int}")
	rt ret
End Function
function upf_1_upd()
	dim sqla(10),ret
	sqla(0)=xg("[baseinfo]","name1,name2,name3","id={id:int}")
	ret=execsw(sqla)
	rt ret	
end function
function upf_1_lst()
	dim i,arr,j
	dim data_id,card_title,card_p,time_show,href
	
	arr= sql2arr("select id,name1,name2,name3,tt1,tpage from antique  where (1=1) and "& " tt1 " & hr_b(val("log1_search")) &" order by id")
	if ubound(arr)>0 then
		for i=0 to ubound(arr,2)
			data_id=arr(0,i)
			card_title=arr(2,i)
			card_p=arr(4,i)
			time_show="共 " & arr(5,i) & " 页"
			href="upf_2_1.asp?tpage="& arr(5,i) &"&tt1="&card_p&"&name3="&arr(3,i)
			echo myjs1("card_upf_1.js","data-id|"& data_id &",card_title|" & card_title  &",card_p|"&   card_p   & ",time|" & time_show &",href|" & href)
		next
	end if
end function
function upf_1_count()
	dim i,arr,title_
	sql="select id from antique where (1=1) and (2=2) and (3=3) and (4=4)"
	echo rc(sql)
end function
function code_list()
	dim i,arr,title_,sql
	sql="select fxpwd,title1 from log1 where (id={log1_id1:int}) and (1=1) and (2=2) and (3=3) and (4=4)"
	s1 sql
	title_="<p id='title1' style='color: #009688;font-size: 24px;padding-bottom: 15px;font-family: Lato,  Helvetica, Arial, sans-serif;'>" & val("title1") &"</p>"
	echo title_  & "<br>" & val("fxpwd")
end function
function code_del()
	dim ret
	vas "mode","onc_1"
	ret = Easp.Db.Del("[baseinfo]","mode={mode}")
	Easp.Fso.DelFile "c_run/*.bat"
	Easp.Fso.DelFile "upload/*.bat"
	Easp.Fso.DelFile "upload/*.c"
	Easp.Fso.DelFile "upload/*.cc"
	Easp.Fso.DelFile "upload/*.cpp"

	Easp.Fso.DelFile "upload/*.out"
	Easp.Fso.DelFile "upload/*.rout"
	Easp.Fso.DelFile "upload/*.exe"
	Easp.Fso.DelFile "upload/*.asp"
	Easp.Fso.DelFile "upload/*.php"

  'Easp.Db.Del "[baseinfo]","mode='onc_1'"
  'Easp.Db.Del "[user]","username<>'admin'"
  'Easp.Db.Del "[log1]","1=1"
end function
function code_add()
	dim sqla(10),fname
	'fname=cint(Easp.Str.RandomNumber(1, 4000))
	fname=Easp.Str.RandomStr("<8>_<6>:0123456789ABCDEF")
	Easp.Fso.CreateFile "upload/"& fname & "."&val("name3"),val("code")
	vas "mode","onc_1"
	vas "name2",fname
	sqla(0)=cr2("[baseinfo]","mode,name1,name2,name3")
	ret=execsw(sqla)
	rt2 ret,fname
end function

Function get_m_f()
	dim sqla(10),out1
	out1 = Easp.Fso.Read("m/" & val("fname"))
	echo out1
End Function
Function runr_get0()
	dim sqla(10),out1,out0
	out1 = Easp.Fso.Read("upload/"& val("fname"))
	if right(val("fname"),4)="rout"  then
		s1 "select ans from log1 where id=" & Easp.IIF(val("log1_id1")<>"", val("log1_id1"), "0")
		if val("ans")<>"" then
			if trim(val("ans")) = trim(out1) then
				out0="您的得分：100 再接再厉" 
			else
				out0="您的得分：0 不要气馁" 
			end if
			out1=out0 & lf & lf & "您的答案："& out1
			out1=out1 & lf & "标准答案：" & val("ans")
		end if
		s1 "select value1 from baseinfo where name2="&da(scw(val("fname"),".rout"))
		echo "运行耗时："&val("value1")&" 毫秒"& lf &lf
	end if
	if Easp.Fso.isExists("upload/"& val("fname"))=true then
	else
		out1="请检查输入文件名是否正确"
	end if

	echo out1
End Function

Function log1_get()
	dim sql,txt
	sql="select questionDescription from log1 where (1=1) and id={log1_id1:int}"
	s1 sql
	txt=replace(val("questionDescription"),"’","'")
	txt=replace(txt,"‘","'")
	echo txt
end function

function r_session()
	dim tmp
	tmp=session(val("r_session"))
	echo tmp
	if tmp="" and val("r_session")="opentime" then
		session("opentime")=Format_Time(now(),1)
	end if
end function

function json_help(key,value)
	dim txt
	txt= syh(key)&":"& value
	json_help=txt
end function

Function log1_del()
	dim sqla(10),rc1
	ret = Easp.Db.Del("[log1]","id={id:int}")
	ret=execsw(sqla)
	rt ret
End Function

Function test()
	dim sql,arr
	sql="select questionDescription from log1 where questionDescription like '*''*'"
end function

Function batchQrjf()
	dim result,ob,i,ids,ret
	Set ob = toArray(json)
	For i=0 To ob.Count-1
		easp.var("id")=ob(i)("ID")
		set rs=easp.db.sel("select qrjf from [jf] where id={id}")
		if rs("qrjf")=0 then
			ret=Easp.Db.Upd ("[jf]","qrjf=1","id={id}")    	
		end if
	next
	Set ob = Nothing
End Function
%>